#include "../utilities/layerEarth_MT.h"
#include "iostream"
#include "fstream"

int main(int argc, char const *argv[])
{
	// Test code for liu lian on 2022-06-10
	std::ifstream infile("layer-liulian.txt");

	double tmp_d, z[39];
	for (size_t i = 0; i < 39; i++)
	{
		infile >> z[i] >> tmp_d >> tmp_d;
	}

	infile.close();
	// End test code

	std::vector<conductive_layer> layer_model(3);
	layer_model[0].set(1e-10, 1, 1, 0);
	layer_model[1].set(0.01, 1, 1, 1e+4);
	layer_model[2].set(0.05, 1, 1, 1e+20);

	layerEarthMT le_(layer_model);

	// Test code for liu lian on 2022-06-10
	std::complex<double> ex[39], ey[39];

	le_.set_to_TE_mode();
	le_.initialize();

	for (size_t i = 0; i < 39; i++)
	{
		le_.calculate_EH(z[i], 0.0);
		ex[i] = le_.get_Ex();
	}

	le_.set_to_TM_mode();
	le_.initialize();

	for (size_t i = 0; i < 39; i++)
	{
		le_.calculate_EH(z[i], 0.0);
		ey[i] = le_.get_Ey();
	}

	std::cout << "# depth(m) Re(Ex) Im(Ex) Re(Ey) Im(Ey)\n";
	for (int i = 0; i < 39; ++i)
	{
		std::cout << z[i] << " " << ex[i].real() << " " << ex[i].imag() 
			<< " " << ey[i].real() << " " << ey[i].imag() << std::endl;
	}
	// End test code

	/*
	std::complex<double> ex[101], ey[101];

	le_.set_to_TE_mode();
	le_.initialize();

	for (int i = 0; i < 101; ++i)
	{
		le_.calculate_EH(1000*i - 20000, 0.0);
		ex[i] = le_.get_Ex();
	}

	le_.set_to_TM_mode();
	le_.initialize();

	for (int i = 0; i < 101; ++i)
	{
		le_.calculate_EH(1000*i - 20000, 0.0);
		ey[i] = le_.get_Ey();
	}

	std::cout << "# depth(m) Re(Ex) Im(Ex) Re(Ey) Im(Ey)\n";
	for (int i = 0; i < 101; ++i)
	{
		std::cout << 1000*i - 20000 << " " << ex[i].real() << " " << ex[i].imag() 
			<< " " << ey[i].real() << " " << ey[i].imag() << std::endl;
	}
	*/
	return 0;
}